var page = sm("do_Page");
var app = sm("do_App");
var openHelper = require("helper/open");
var nf = sm("do_Notification");
var rootview = ui("$");
var shareUtil = require("helper/share");
var userUrl = require("url/user");
var userHelper = require("helper/user");
var httpSilence = require("helper/httpSilence");
var deviceUtil = require("helper/device");
//遮罩显示
var animMaskShow = mm("do_Animator");
var propsMS = {bgColor:"00000077"};
animMaskShow.append(300,propsMS,"EaseOut");
//面板显示
var animPanelShow = mm("do_Animator");
var propsPS = {y:760};
animPanelShow.append(300,propsPS,"Linear");
//遮罩隐藏
var animMaskHide = mm("do_Animator");
var propsMH = {bgColor:"00000000"};
animMaskHide.append(300,propsMH,"EaseIn");
//面板隐藏
var animPanelHide = mm("do_Animator");
var propsPH = {y:960};
animPanelHide.append(300,propsPH,"EaseIn");

//遮罩事件
var maskbg = ui("bgmask");
maskbg.on("touch","",300,function(){
	maskbg.animate(animMaskHide,function(){
		maskbg.visible = false;
	});
	bodyp.animate(animPanelHide);
});
//防止穿透
var bodyp = ui("pbody");
bodyp.on("touch","",300,function(){
	
});
//确定  
var buttonCancel = ui("buttonCancel");
buttonCancel.on("touch","",300,function(){
	maskbg.animate(animMaskHide,function(){
		maskbg.visible = false;
	});
	bodyp.animate(animPanelHide);
});
page.on("share_close","",300,function(){
	if(shareType==shareUtil.type.DRAW){//增加抽奖次数
		httpSilence.post(userUrl.url.value.addDrawCount, {}, function(data) {
			if(data.hasDrawCount){
				page.fire("draw_share_addCount",{"type":3,bizzId:userHelper.userId()})
			}
		})
	}
	maskbg.animate(animMaskHide,function(){
		maskbg.visible = false;
	});
	bodyp.animate(animPanelHide);
});
//zdy
var shareTitle="",shareContent="",shareImage="",shareId,shareType;
page.on("onShare",function(data){
	maskbg.visible = data.showView;
	shareTitle=data.shareTitle;
	shareTitle = shareTitle.replace(/\n/g,'').replace(/^\s+|\s+$/g, '');//替换【换行符】替换【空格】
	
	shareContent=data.shareContent;
	shareContent = shareContent.replace(/\n/g,'').replace(/^\s+|\s+$/g, '');//替换【换行符】替换【空格】
	
	shareImage=data.shareImage;
	shareType=data.shareType;
	shareId=data.shareId;
	maskbg.animate(animMaskShow);
	bodyp.animate(animPanelShow);
});
//微信朋友
ui("do_ALayout_7").on("touch","", 3000,function(){
	shareUtil.wxShareFriend(shareTitle,shareContent,shareImage,null,shareType,shareId);
});
//微信朋友圈
ui("do_ALayout_9").on("touch","", 3000,function(){
	shareUtil.wxShareFriendCircle(shareTitle,shareContent,shareImage,null,shareType,shareId);
});
//qq好友
ui("do_ALayout_11").on("touch","", 3000,function(){
	shareUtil.qqShareFriend(shareTitle,shareContent,shareImage,null,shareType,shareId);
});
//新浪
ui("do_ALayout_13").on("touch","", 3000,function(){
	shareUtil.sinaShare(shareTitle,shareContent,shareImage,null,shareType,shareId);
});
//qq空间
ui("do_ALayout_15").on("touch","", 3000,function(){
	shareUtil.qqShareQzone(shareTitle,shareContent,shareImage,null,shareType,shareId);
});